package com.example.demo.service.impl;

import com.example.demo.common.ResponseMessage;
import com.example.demo.dao.OrderDetailsMapper;
import com.example.demo.dao.OrderMapper;
import com.example.demo.pojo.Order;
import com.example.demo.pojo.OrderDetails;
import com.example.demo.service.IOrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("iOrderService")
public class OrderServiceImpl implements IOrderService {
    @Autowired
    private OrderMapper orderMapper;
    private OrderDetailsMapper orderDetailsMapper;
    @Override
    public int addOrder(Order order) {
        return orderMapper.insert(order);
    }

    @Override
    public ResponseMessage getProductInfo(long orderId) {
        List<OrderDetails> orderDetailsList = orderDetailsMapper.selectProduct(orderId);
        ResponseMessage msg = new ResponseMessage(orderDetailsList);
        return msg;
    }

    @Override
    public ResponseMessage getOrderList(int userId) {
        //获取session
        //userId = session()
        //userId = 1;
        List<Order> orderList = orderMapper.selectAll(userId);
        ResponseMessage msg = new ResponseMessage(orderList);
        return msg;
    }

    @Override
    public int deleteOrder(long orderNo) {
        return orderMapper.deleteByOrderNo(orderNo);
    }

    @Override
    public int getStatus(long orderNo) {
        return orderMapper.selectStatus(orderNo);
    }


}
